const UserModel = require("../models/UserModel");

/**
 *
 * @param {String} username
 * @param {String} password
 * @returns {Object} register success info
 */
async function userRegister(username, password) {
  const res = await UserModel.create({
    username,
    password,
  });
  return res;
}

async function userLogin(username, password) {
  const res = await UserModel.findOne({
    username,
    password,
  });
  return res;
}

async function getUserinfo(username) {
  const res = await UserModel.findOne({
    username,
  });
  return res;
}

module.exports = {
  userRegister,
  userLogin,
  getUserinfo,
};
